package com.yannickstucki.android.musicqueue.widget;

import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

import com.yannickstucki.android.musicqueue.R;
import com.yannickstucki.android.musicqueue.data.DbAdapter;

/**
 * This is a receiver used to process user actions on the widget.
 */
public final class WidgetChange extends BroadcastReceiver {

  /**
   * This is the function that should be called externally to communicate with
   * the widget (normally we just tell it to refresh its state).
   */
  public static void refresh(final RemoteViews rv, final Context c) {

  }

  @Override
  public void onReceive(final Context c, final Intent intent) {
    final RemoteViews rv = new RemoteViews(c.getPackageName(), R.layout.widget);
    switch (intent.getExtras().getInt(DbAdapter.KEY_ROWID)) {
    case R.id.widgetPlay:
      break;
    case R.id.widgetNext:
      break;
    default:
      break;
    }
    AppWidgetManager.getInstance(c).updateAppWidget(
        new ComponentName(c, Widget.class), rv);
  }
}
